const Cesium = window.Cesium;
let viewer = null;

function createCesium(id) {
    var imageryProvider = new Cesium.WebMapTileServiceImageryProvider({
        url: 'http://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=189b1925501a5ece0893939e50df0304',
        layer: 'img',
        style: 'default',
        format: 'tiles',
        tileMatrixSetID: 'w',
        credit: new Cesium.Credit('天地图全球影像服务'),
        maximumLevel: 7,
        show: true,
      });

    viewer = new Cesium.Viewer(id, {
        // terrain: Cesium.Terrain.fromWorldTerrain(),
        animation: false,
        fullscreenButton: true,
        geocoder: false,
        homeButton: false,
        infoBox: false,
        sceneModePicker: false,
        selectionIndicator: false,
        timeline: false,
        navigationHelpButton: false,
        baseLayerPicker: false,
        navigationInstructionsInitiallyVisible: false,
        // imageryProvider: imageryProvider,
    });
    //鼠标右键切换视角
    viewer.scene.screenSpaceCameraController.tiltEventTypes = [Cesium.CameraEventType.RIGHT_DRAG];
    //隐藏原生logo
    viewer._cesiumWidget.creditContainer.style.display = 'none';

    viewer.scene.logarithmicDepthBuffer = false;



    //深度检测
    viewer.scene.globe.depthTestAgainstTerrain = true
    // viewer.scene.globe.enableLighting = false;
    //显示帧速
    viewer.scene.debugShowFramesPerSecond = true;
    //关闭灯光
    viewer.scene.globe.enableLighting = false;
    //关闭阴影
    viewer.shadows = false;
    //修正光照
    // viewer.scene.light = new Cesium.DirectionalLight({
    //     direction: new Cesium.Cartesian3(0.35492591601301104, -0.8909182691839401, -0.2833588392420772),
    //     // direction: Cesium.Cartesian3.fromDegrees(113.200150, 21.990197, 1000),
    //     // color: Cesium.Color.fromCssColorString("yellow"),
    //     intensity: 1
    // });


    // viewer.scene.skyBox.show = false;
    // viewer.scene.backgroundColor = new Cesium.Color.fromCssColorString(
    //     "#0050A4"
    // );
    viewer.scene.sun.show = false;
    viewer.scene.moon.show = false;
    // viewer.scene.globe.show = false;
    // viewer.scene.skyAtmosphere.show = false; //隐藏大气圈
}

export {
    createCesium,
    viewer
}